<body>
    <p>This tests that the video element's "controls" attribute is overridden in full screen mode, and that the controls are correctly hidden upon exiting full screen.  Press any key to continue.</p>
    <video id="video" width="300"></video>
    <script src="full-screen-test.js"></script>
    <script src="../media/media-controls.js"></script>
    <script>
        var callback;
        var shadowRoot;
        var panel;

        var fullscreenChanged = function(event)
        {
            if (callback)
                callback(event)
        };
        waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);

        var video = document.getElementById('video');

        var videoEnteredFullScreen = function() {
            if (window.internals) {
                testExpected("shadowRoot = internals.shadowRoot(video)", null, "!=");
                testExpected("panel = mediaControlsElement(shadowRoot.firstChild, '-webkit-media-controls-panel')", null, "!=");
                testExpected("internals.shadowPseudoId(panel)", "-webkit-media-controls-panel");
                testExpected("document.defaultView.getComputedStyle(panel)['display']", 'none', "!=");
                testExpected("document.defaultView.getComputedStyle(panel)['height']", '20px', ">=");
            }
            else
                logResult(false, "window.internals == undefined");
            
            callback = cancelledFullScreen;
            document.webkitCancelFullScreen();
        };

        var cancelledFullScreen = function() {
            if (window.testRunner)
                testExpected("document.defaultView.getComputedStyle(panel)['display']", 'none');
            else
                logResult(false, "window.testRunner == undefined");

            endTest();
        };

        callback = videoEnteredFullScreen;
        runWithKeyDown(function(){video.webkitRequestFullScreen()});
    </script>
</body>
